<?php TPL::output('admin/global/header.tpl.htm'); ?>
<?php TPL::output('admin/global/nav_menu.tpl.htm'); ?>

<div class="aw-content-wrap">
    <div class="mod">
        <div class="mod-head">
            <h3>
                <ul class="nav nav-tabs">
                    <li class="active"><a href="admin/help/list/"><?php _e('章节管理'); ?></a></li>
                    <li><a href="admin/help/edit/"><?php _e('新建章节'); ?></a></li>
                </ul>
            </h3>
        </div>

        <div class="tab-content mod-body">
            <div class="alert alert-success collapse error_message"></div>

            <div class="table-responsive">
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th><?php _e('标题'); ?></th>
                        <th><?php _e('排序'); ?></th>
                        <th><?php _e('操作'); ?></th>
                    </tr>
                    </thead>
                    <?php if ($this->chapter_list) { ?>
                    <tbody>
                    <form id="chapter_form" action="admin/ajax/help/save_chapter_sort/" method="post" onsubmit="return false">
                    <?php foreach ($this->chapter_list AS $chapter_info) { ?>
                    <tr>
                        <td>
                            <a href="help/<?php echo $chapter_info['id']; ?>"><?php echo $chapter_info['title']; ?></a>
                        </td>
                        <td>
                            <div class="col-sm-6 clo-xs-12 col-lg-offset-3">
                                <input type="text" class="form-control sort-action" name="sort[<?php echo $chapter_info['id']; ?>]" value="<?php echo $chapter_info['sort']; ?>" />
                            </div>
                        </td>
                        <td >
                            <a href="admin/help/edit/<?php echo $chapter_info['id']; ?>" data-toggle="tooltip" class="icon icon-edit md-tip" title="<?php _e('编辑'); ?>"></a>
                            <a onclick="AWS.ajax_request(G_BASE_URL + '/admin/ajax/help/remove_chapter/', 'id=<?php echo $chapter_info['id'];?>');" data-toggle="tooltip" class="icon icon-trash md-tip" title="<?php _e('删除'); ?>"></a>
                        </td>
                    </tr>
                    <?php } ?>
                    </form>
                    </tbody>
                    <?php } ?>
                </table>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function() {
        $('input.sort-action').keyup(function() {
            if ($(this).val() != '')
            {
                AWS.ajax_post($('#chapter_form'), AWS.ajax_processer, 'error_message');
            }
        });
    });
</script>

<?php TPL::output('admin/global/footer.tpl.htm'); ?>